<?
class App_memberModel extends AppModel {
    protected $tableName='member';
    protected $_map=array(//字符映射
        'user_id'=>'id',
        'device_id'=>'loginapp',
        'group'=>'groupname',
        'Position'=>'positionname',
        'name'=>'username',
        'phone'=>'tel',
        'siteId'=>'site_id',
        'userIcon'=>'img_url',
    );
//    public function login(){
//        $data=$this->where('site_id = 13')->find();
//        return $this->parseFieldsMap($data);
//    }
    public function doLogin($map){
        $check=D('Member')->where($map)->field('id,nickname,name,loginapp,site_id,group_id,pid,position_id,login_ip')->find();
        $data = $check?$this->parseFieldsMap($check):'';
        return $data;
    }
    //获取全部联系人  //获取单个联系人
    public function member($map,$type){
        if($type=='0'){//全部
            $check=D('member')->alias('m')->join('__MEMBER_GROUP__ g on g.id=m.group_id')->join('__MEMBER_POSITION__ p on p.id =m.position_id')->where($map)->field('m.id,m.username,m.tel,m.address,m.qq,m.email,m.remark,g.title as groupname,p.name as positionname,img_url,nickname')->select();
        }elseif($type='1'){//单个
            $check=D('member')->alias('m')->join('__MEMBER_GROUP__ g on g.id=m.group_id')->join('__MEMBER_POSITION__ p on p.id =m.position_id')->where($map)->field('m.id,m.username,m.tel,m.address,m.qq,m.email,m.remark,g.title as groupname,p.name as positionname,img_url,nickname')->find();
        }
        $data = $check?$this->parseFieldsMap($check):'';
        return $data;
    }

}